package com.csit.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

/**
 * 
 * @Description: 损耗实体
 * @Copyright: 福州骏华信息有限公司 (c)2012
 * @Created Date : 2012-12-8
 * @author longweier
 * @vesion 1.0
 */
@Entity
@Table(name="T_Wastage")
public class Wastage implements Serializable {

	private static final long serialVersionUID = -5235786929446105759L;

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private Integer wastageID;
	
	@Column(precision=2)
	private Double quantity;
	
	@Column(precision=2)
	private Double price;
	
	private Double amount;
	
	@Column(length=100)
	private String operater;

	@Column(updatable=false,nullable=false)
	@Temporal(TemporalType.DATE)
	private Date createDate;
	
	@Column(length=1000)
	private String note;
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="productID")
	private Product product;
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="shopID",updatable=false)
	private DataDictionary shop;

	public Integer getWastageID() {
		return wastageID;
	}

	public void setWastageID(Integer wastageID) {
		this.wastageID = wastageID;
	}

	public Double getQuantity() {
		return quantity;
	}

	public void setQuantity(Double quantity) {
		this.quantity = quantity;
	}

	public Double getPrice() {
		return price;
	}

	public void setPrice(Double price) {
		this.price = price;
	}

	public Double getAmount() {
		return amount;
	}

	public void setAmount(Double amount) {
		this.amount = amount;
	}

	public String getOperater() {
		return operater;
	}

	public void setOperater(String operater) {
		this.operater = operater;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public String getNote() {
		return note;
	}

	public void setNote(String note) {
		this.note = note;
	}

	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	public DataDictionary getShop() {
		return shop;
	}

	public void setShop(DataDictionary shop) {
		this.shop = shop;
	}

	@Transient
	public void setShopID(Integer shopID){
		if(shop==null){
			shop = new DataDictionary();
		}
		shop.setDataDictionaryID(shopID);
	}
}
